﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;


namespace letGo
{
    


    public class myBaseClass
    {
        //protected SqlConnection Conn = null;
        ////protected OleDbConnection conn;
        //protected String constr;
        //protected int count;
        //public SqlDataAdapter da;
        ////protected OleDbDataAdapter da;
        //protected DataSet ds;
        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

        public void readDataSet(string user, UserLoginInfo _UserLoginInfo)
        {
            //string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            using (SqlConnection con = new SqlConnection(constr))
            {
                
                con.Open();
                SqlCommand cm = new SqlCommand(user, con);
                cm.Parameters.AddWithValue("@username", _UserLoginInfo.UserName);
                cm.Parameters.AddWithValue("@password", _UserLoginInfo.UserPassword);
                cm.Parameters.AddWithValue("@email", _UserLoginInfo.UserEmail);
                cm.Parameters.AddWithValue("@RegistedTime", _UserLoginInfo.UserRegistedTime);
                cm.Parameters.AddWithValue("@usertype", _UserLoginInfo.UserType);
                //cm.Parameters.AddWithValue("@login_date", System.DateTime.Now);
                cm.ExecuteNonQuery();

            }
        }


        public bool isFound(string str)
        {
            using (SqlConnection con = new SqlConnection(constr))
            {
                SqlDataReader dr;
                con.Open();

                SqlCommand cm = new SqlCommand(str, con);
                dr = cm.ExecuteReader();
                if (dr.Read())
                    return true;
                else
                    return false;

            }
           
        }
    }


    public class UserLoginInfo
    {
        public string UserName = "";
        public string UserPassword = "";
        public string UserEmail = "";
        public string UserRegistedTime = DateTime.Now.ToString();
        public string UserType = "1";
    }
}